import { VantComponent } from '../../vant-weapp/dist/common/component'
VantComponent({
  props: {
    customClass: String,
    bottom: {
      type: Number,
      value: 20
    },
    height: {
      type: Number,
      value: 0
    },
    border: {
      type: Boolean,
      value: true
    },
    background: String
  },
  data: {
    safeAreaHeight: 0,
    boxHeight: 0
  },
  created () {
    this.setData({
      safeAreaHeight: this.getInitialSafeArea()
    })
  },
  mounted () {
    this.initRect()
  },
  methods: {
    initRect () {
      var query = wx.createSelectorQuery().in(this)
      query.select('#box').boundingClientRect((res) => {
        console.log('boxRect:', res)
        this.setData({
          boxHeight: res.height
        })
      }).exec()
    },
    getInitialSafeArea () {
      console.log('getSafeAreaHeight:')
      var systemInfo = wx.getStorageSync('systemData') || wx.getSystemInfoSync()
      console.log('getSafeAreaHeight:', systemInfo)
      return systemInfo.screenHeight - systemInfo.safeArea.bottom
    }
  }
})
